//////////////////////////////////////////////////////////
// This class has been automatically generated on
// Thu Jul 19 23:05:30 2012 by ROOT version 5.32/00
// from TTree Ntuple/Ntuple
// found on file: Herwig_glu300_ntuple.root
//////////////////////////////////////////////////////////

#ifndef Ntuple_h
#define Ntuple_h

#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TSelector.h>
#include <iostream>
#include <string>
#include <TH1D.h>

// Header file for the classes stored in the TTree if any.

// Fixed size dimensions of array or collections stored in the TTree if any.

class Ntuple : public TSelector {
public :
   TTree          *fChain;   //!pointer to the analyzed TTree or TChain

   Double_t        scale;
   bool            b_QCD;
   // Declaration of leaf types
   Double_t        weight;
   Int_t           n;
   Double_t        e[20];   //[n]
   Double_t        px[20];   //[n]
   Double_t        py[20];   //[n]
   Double_t        pz[20];   //[n]
   Double_t        pt[20];   //[n]
   Double_t        m[20];   //[n]
   Double_t        tau1_1[20];   //[n]
   Double_t        tau2_1[20];   //[n]
   Double_t        tau3_1[20];   //[n]
   Double_t        tau1_2[20];   //[n]
   Double_t        tau2_2[20];   //[n]
   Double_t        tau3_2[20];   //[n]
   Double_t        tau1_kt[20];   //[n]
   Double_t        tau2_kt[20];   //[n]
   Double_t        tau3_kt[20];   //[n]

   // List of branches
   TBranch        *b_weight;   //!
   TBranch        *b_n;   //!
   TBranch        *b_e;   //!
   TBranch        *b_px;   //!
   TBranch        *b_py;   //!
   TBranch        *b_pz;   //!
   TBranch        *b_pt;   //!
   TBranch        *b_m;   //!
   TBranch        *b_tau1_1;   //!
   TBranch        *b_tau2_1;   //!
   TBranch        *b_tau3_1;   //!
   TBranch        *b_tau1_2;   //!
   TBranch        *b_tau2_2;   //!
   TBranch        *b_tau3_2;   //!
   TBranch        *b_tau1_kt;   //!
   TBranch        *b_tau2_kt;   //!
   TBranch        *b_tau3_kt;   //!

   Ntuple(TTree * /*tree*/ =0) : fChain(0) { }
   virtual ~Ntuple() { }
   virtual Int_t   Version() const { return 2; }
   virtual void    Begin(TTree *tree);
   virtual void    SlaveBegin(TTree *tree);
   virtual void    Init(TTree *tree);
   virtual Bool_t  Notify();
   virtual Bool_t  Process(Long64_t entry);
   virtual Int_t   GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }
   virtual void    SetOption(const char *option) { fOption = option; }
   virtual void    SetObject(TObject *obj) { fObject = obj; }
   virtual void    SetInputList(TList *input) { fInput = input; }
   virtual TList  *GetOutputList() const { return fOutput; }
   virtual void    SlaveTerminate();
   virtual void    Terminate();

   ClassDef(Ntuple,0);
};

#endif

#ifdef Ntuple_cxx
void Ntuple::Init(TTree *tree)
{
   // The Init() function is called when the selector needs to initialize
   // a new tree or chain. Typically here the branch addresses and branch
   // pointers of the tree will be set.
   // It is normally not necessary to make changes to the generated
   // code, but the routine can be extended by the user if needed.
   // Init() will be called many times when running on PROOF
   // (once per file to be processed).

   // Set branch addresses and branch pointers
   if (!tree) return;
   fChain = tree;
   fChain->SetMakeClass(1);

   fChain->SetBranchAddress("weight", &weight, &b_weight);
   fChain->SetBranchAddress("n", &n, &b_n);
   fChain->SetBranchAddress("e", e, &b_e);
   fChain->SetBranchAddress("px", px, &b_px);
   fChain->SetBranchAddress("py", py, &b_py);
   fChain->SetBranchAddress("pz", pz, &b_pz);
   fChain->SetBranchAddress("pt", pt, &b_pt);
   fChain->SetBranchAddress("m", m, &b_m);
   fChain->SetBranchAddress("tau1_1", tau1_1, &b_tau1_1);
   fChain->SetBranchAddress("tau2_1", tau2_1, &b_tau2_1);
   fChain->SetBranchAddress("tau3_1", tau3_1, &b_tau3_1);
   fChain->SetBranchAddress("tau1_2", tau1_2, &b_tau1_2);
   fChain->SetBranchAddress("tau2_2", tau2_2, &b_tau2_2);
   fChain->SetBranchAddress("tau3_2", tau3_2, &b_tau3_2);
   fChain->SetBranchAddress("tau1_kt", tau1_kt, &b_tau1_kt);
   fChain->SetBranchAddress("tau2_kt", tau2_kt, &b_tau2_kt);
   fChain->SetBranchAddress("tau3_kt", tau3_kt, &b_tau3_kt);

   string filename(fChain->GetCurrentFile()->GetName());
   TH1D* c_hist=(TH1D*) fChain->GetCurrentFile()->Get("nevt");
   double c_nevt=c_hist->Integral(0,1);

   b_QCD=false;

   if(filename.find("QCD")!=string::npos)
     {
       b_QCD=true;
     }
   else
     {
       c_nevt= ((TH1D*) fChain->GetCurrentFile()->Get("nevt_unweighted"))
	 ->Integral(0,1);
     }


   if(filename.find("QCD")!=string::npos)
     {
       scale=7.60016e9/c_nevt;
       b_QCD=true;
     }
   else if(filename.find("300")!=string::npos)
     scale=62.1e3/c_nevt;
   else if(filename.find("350")!=string::npos)
     scale=24.3e3/c_nevt;
   else if(filename.find("400")!=string::npos)
     scale=10.4e3/c_nevt;
   else if(filename.find("450")!=string::npos)
     scale=4.8e3/c_nevt;
   else if(filename.find("500")!=string::npos)
     scale=2.34e3/c_nevt;
   else if(filename.find("550")!=string::npos)
     scale=1.19e3/c_nevt;
   else if(filename.find("600")!=string::npos)
     scale=.628e3/c_nevt;
   else if(filename.find("650")!=string::npos)
     scale=.342e3/c_nevt;
   else if(filename.find("700")!=string::npos)
     scale=.191e3/c_nevt;
   else if(filename.find("750")!=string::npos)
     scale=.109e3/c_nevt;
   else if(filename.find("800")!=string::npos)
     scale=6.33e1/c_nevt;
   else if(filename.find("850")!=string::npos)
     scale=3.73e1/c_nevt;
   else if(filename.find("900")!=string::npos)
     scale=2.23e1/c_nevt;
   else if(filename.find("950")!=string::npos)
     scale=1.35e1/c_nevt;

}

Bool_t Ntuple::Notify()
{
   // The Notify() function is called when a new file is opened. This
   // can be either for a new TTree in a TChain or when when a new TTree
   // is started when using PROOF. It is normally not necessary to make changes
   // to the generated code, but the routine can be extended by the
   // user if needed. The return value is currently not used.

   return kTRUE;
}

#endif // #ifdef Ntuple_cxx
